﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;

//using PowerCreator.LMS.Logic.Common;
//using PowerCreator.LMS.Model.Entity;
//using PowerCreator.LMS.Logic.PaperManager;
//using PowerCreator.LMS.Logic.QuestionManager;

public partial class sysadmin_CountManager_PaperCountUserList : PowerCreator.LMS.Web.Base.BasePage
{
    //ManagerPaperInfo objPaperInfo = new ManagerPaperInfo();
    //ManagerUserPaperHistoryInfo objUserPaperHistorylogic = new ManagerUserPaperHistoryInfo();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
           // ViewState["PaperID"] = Base64.Decode(Request.QueryString["p"].ToString());
            //PaperInfo pinfo = objPaperInfo.Load(int.Parse(ViewState["PaperID"].ToString()));
            ////ViewState["PaperName"] = Base64.Decode(Request.QueryString["pn"].ToString());
            //lab_PaperName.Text = pinfo.PaperName;
            //string search = GetSearch();
            //BinderPager(search);
            //BinderGV(search, 1);
        }
    }

    private string GetSearch()
    {
        //int paperID = int.Parse(ViewState["PaperID"].ToString());
        //string username = txt_UserName.Text.Trim();
        StringBuilder search = new StringBuilder();
        //search.Append(" and UserPaperHistoryInfo.PaperID='" + paperID + "'");
        //if (!string.IsNullOrEmpty(username))
        //{
        //    search.Append(" and UserName like '%" + username + "%' ");
        //}
        return search.ToString();
    }
    private void BinderPager(string search)
    {
        //AspNetPager1.RecordCount = objUserPaperHistorylogic.PaperUserListCount(search);
        //AspNetPager1.PageSize = FBasePage.PageSize();
    }

    private void BinderGV(string search, int pageIndex)
    {
        //DataTable dt = new DataTable();
        //dt = objUserPaperHistorylogic.PaperUserList(search, pageIndex, FBasePage.PageSize());
        //ViewState["dt"] = dt;
        //gvUserPaperList.DataSource = dt;
        //gvUserPaperList.DataBind();
    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        string search = GetSearch();
        BinderPager(search);
        BinderGV(search, 1);
    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        string search = GetSearch();
        BinderGV(search, AspNetPager1.CurrentPageIndex);
    }

    protected void gvUserPaperList_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("bgColor", "#F7FAFF");
            e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#FAEDB8'");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#F7FAFF'");
        }
    }
    protected void btnExport_Click(object sender, EventArgs e)
    {        
        DataTable dt = (DataTable)ViewState["dt"];
        ExportList(dt);
    }
    private void ExportList(DataTable dt)
    {
        //ArrayList list = new ArrayList();
        //for (int i = 0; i < dt.Columns.Count; i++)
        //{
        //    if (dt.Columns[i].ColumnName == "UserID")
        //    {
        //        dt.Columns[i].ColumnName = "用户ID";
        //        dt.Columns[i].SetOrdinal(0);
        //    }
        //    else if (dt.Columns[i].ColumnName == "UserName")
        //    {
        //        dt.Columns[i].ColumnName = "姓名";
        //        dt.Columns[i].SetOrdinal(1);
        //    }
        //    else if (dt.Columns[i].ColumnName == "ProjectName")
        //    {
        //        dt.Columns[i].ColumnName = "方案名称";
        //        dt.Columns[i].SetOrdinal(2);
        //    }

        //    else if (dt.Columns[i].ColumnName == "ClassName")
        //    {
        //        dt.Columns[i].ColumnName = "班级名称";
        //        dt.Columns[i].SetOrdinal(3);
        //    }

        //    else if (dt.Columns[i].ColumnName == "PaperStateDate")
        //    {
        //        dt.Columns[i].ColumnName = "开始时间";
        //        dt.Columns[i].SetOrdinal(4);
        //    }
        //    else if (dt.Columns[i].ColumnName == "SubmitDate")
        //    {
        //        dt.Columns[i].ColumnName = "结束时间";
        //        dt.Columns[i].SetOrdinal(5);
        //    }
        //    else if (dt.Columns[i].ColumnName == "PaperScore")
        //    {
        //        dt.Columns[i].ColumnName = "得分";
        //        dt.Columns[i].SetOrdinal(6);
        //    }
        //    else
        //    {
        //        list.Add(dt.Columns[i].ColumnName);
        //    }

        //}
        //for (int i = 0; i < list.Count; i++)
        //{
        //    dt.Columns.Remove(list[i].ToString());
        //}
        //Excel objExcel = new Excel();
        //objExcel.ToExcel(dt, this.Page, "试卷统计", "试卷统计信息", "PaperInfo");
    }
    protected void btnExport_All_Click(object sender, EventArgs e)
    {
        //string search = GetSearch();
        //DataTable dt = new DataTable();
        //dt = objUserPaperHistorylogic.PaperUserList(search, 1, objUserPaperHistorylogic.PaperUserListCount(search));
        //ExportList(dt);
    }
}
